/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.ylystudio.pms.ejb.entity;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author Kenny Lin
 */
@Entity
@Table(name = "resource_category")
@NamedQueries({
    @NamedQuery(name = "ResourceCategory.findAll", query = "SELECT r FROM ResourceCategory r"),
    @NamedQuery(name = "ResourceCategory.findByRcId", query = "SELECT r FROM ResourceCategory r WHERE r.rcId = :rcId"),
    @NamedQuery(name = "ResourceCategory.findByRcName", query = "SELECT r FROM ResourceCategory r WHERE r.rcName = :rcName"),
    @NamedQuery(name = "ResourceCategory.findByRcDescrip", query = "SELECT r FROM ResourceCategory r WHERE r.rcDescrip = :rcDescrip")})
public class ResourceCategory implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "rc_id")
    private Integer rcId;
    @Basic(optional = false)
    @Column(name = "rc_name")
    private String rcName;
    @Column(name = "rc_descrip")
    private String rcDescrip;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "resourceCategory", fetch = FetchType.LAZY)
    private List<ResourceCategory> resourceCategoryList;
    @JoinColumn(name = "rc_former", referencedColumnName = "rc_id")
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private ResourceCategory resourceCategory;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "resourceCategory", fetch = FetchType.LAZY)
    private List<Resource> resourceList;

    public ResourceCategory() {
    }

    public ResourceCategory(Integer rcId) {
        this.rcId = rcId;
    }

    public ResourceCategory(Integer rcId, String rcName) {
        this.rcId = rcId;
        this.rcName = rcName;
    }

    public Integer getRcId() {
        return rcId;
    }

    public void setRcId(Integer rcId) {
        this.rcId = rcId;
    }

    public String getRcName() {
        return rcName;
    }

    public void setRcName(String rcName) {
        this.rcName = rcName;
    }

    public String getRcDescrip() {
        return rcDescrip;
    }

    public void setRcDescrip(String rcDescrip) {
        this.rcDescrip = rcDescrip;
    }

    public List<ResourceCategory> getResourceCategoryList() {
        return resourceCategoryList;
    }

    public void setResourceCategoryList(List<ResourceCategory> resourceCategoryList) {
        this.resourceCategoryList = resourceCategoryList;
    }

    public ResourceCategory getResourceCategory() {
        return resourceCategory;
    }

    public void setResourceCategory(ResourceCategory resourceCategory) {
        this.resourceCategory = resourceCategory;
    }

    public List<Resource> getResourceList() {
        return resourceList;
    }

    public void setResourceList(List<Resource> resourceList) {
        this.resourceList = resourceList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (rcId != null ? rcId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof ResourceCategory)) {
            return false;
        }
        ResourceCategory other = (ResourceCategory) object;
        if ((this.rcId == null && other.rcId != null) || (this.rcId != null && !this.rcId.equals(other.rcId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.ylystudio.pms.ejb.entity.ResourceCategory[rcId=" + rcId + "]";
    }

}
